//
//  ViewController.m
//  AFNetworkingDemo
//
//  Created by mobao on 16/4/15.
//  Copyright © 2016年 mobao. All rights reserved.
//

#import "ViewController.h"
#import "MyHttp.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)startNetworkStateMonitoring:(id)sender {
    
    [[MyHttp sharedClient]networkStateMonitoring:^(AFNetworkReachabilityStatus status) {
        NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
    }];
    
//    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
//        
//        //开始监控之后，可关闭系统的网络连接，查看打印信息
//        NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
//          
//        
//    }];
    
//    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
}

- (IBAction)endNetworkStateMonitoring:(id)sender {
    
    
}

//新浪公共接口GET请求测试
- (IBAction)getDataFromNetWork:(id)sender {
    
    //具体页面
    NSString *urlString = @"/2/statuses/public_timeline.json";
    
    //请求参数
    NSDictionary *parameter = @{@"access_token":@"2.00NofgBD0L1k4pc584f79cc48SKGdD",@"count":@"2"};
    
    //GET
    [[MyHttp sharedClient]GET:urlString parameters:parameter success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSLog(@"%@",responseObject);
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        NSLog(@"%@",error);
        
    }];

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
